package com.gxa.web_admin.controller.accesscontroller;

import com.gxa.common.R;
import com.gxa.modules.pojo.Organizational;
import com.gxa.modules.pojo.Role;
import com.gxa.modules.pojo.RoleType;
import com.gxa.modules.service.accessservice.OrganizationalService;
import com.gxa.modules.service.accessservice.impl.OrganizationalServiceImpl;
import io.swagger.annotations.*;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

import java.sql.Date;
import java.util.ArrayList;

/**
 * 组织管理
 */
@RestController
@RequestMapping(value = "organizational")
@Api(value = "组织管理模块",tags = "组织管理API")
public class OrganizationalController {

    @Autowired
    private OrganizationalService organizationalService;

    /**
     * 查询所有角色信息
     * @return 返回所有角色信息
     */
    @RequestMapping(value = "selectOrganizational",method = RequestMethod.GET)
    @ApiOperation(value = "查询所有组织信息接口",notes = "根据传入信息查询组织信息",httpMethod = "GET", response = String.class)
    @ApiImplicitParams({
        @ApiImplicitParam(name = "organizationalName",value = "组织名称",paramType = "query",dataType = "String"),
        @ApiImplicitParam(name = "organizationalLevel",value = "组织等级",paramType = "query",dataType = "String"),
        @ApiImplicitParam(name = "page",value = "当前页码",paramType = "query",dataType = "String",required = true),
        @ApiImplicitParam(name = "size",value = "每页显示条数",paramType = "query",dataType = "String",required = true)
    })


    @ApiResponses({
            @ApiResponse(code=200,message="请求成功"),
            @ApiResponse(code=404,message="找不到页面"),
            @ApiResponse(code=500,message="后台服务错误")
    })
    public R selectOrganizational(String organizationalName,String organizationalLevel,String page,String size){
       return organizationalService.selectOrganizational(organizationalName,organizationalLevel,page,size);
    }


    /**
     * 新增组织
     * @return 返回成功
     */
    @RequestMapping(value = "insertOrganizational",method = RequestMethod.POST)
    @ApiOperation(value = "新增组织接口",notes = "新增组织",httpMethod = "POST", response = String.class)
    @ApiResponses({
            @ApiResponse(code=200,message="请求成功"),
            @ApiResponse(code=404,message="找不到页面"),
            @ApiResponse(code=500,message="后台服务错误")
    })
    public R insertOrganizational(@RequestBody @ApiParam(name = "insertOrganizationalJson",
            value = "组织名称、组织等级、组织编号、创建时间",required = true)
                                Organizational organizational){

        return organizationalService.insertOrganizational(organizational);
    }


    /**
     * 删除组织
     * @return 返回删除成功
     */
    @RequestMapping(value = "deleteOrganizational",method = RequestMethod.POST)
    @ApiOperation(value = "删除组织接口",notes = "根据传入id删除组织",httpMethod = "POST", response = String.class)
    @ApiImplicitParam(name = "organizationalId",value = "组织id",paramType = "query",dataType = "String",required = true)
    @ApiResponses({
            @ApiResponse(code=200,message="请求成功"),
            @ApiResponse(code=404,message="找不到页面"),
            @ApiResponse(code=500,message="后台服务错误")
    })
    public R deleteOrganizational(String organizationalId){

        return organizationalService.deleteOrganizational(organizationalId);
    }

    /**
     * 修改组织
     * @return 返回成功
     */
    @RequestMapping(value = "updateOrganizational",method = RequestMethod.POST)
    @ApiOperation(value = "修改组织接口",notes = "修改组织",httpMethod = "POST", response = String.class)
    @ApiResponses({
            @ApiResponse(code=200,message="请求成功"),
            @ApiResponse(code=404,message="找不到页面"),
            @ApiResponse(code=500,message="后台服务错误")
    })
    public R updateOrganizational(@RequestBody @ApiParam(name = "updateOrganizationalJson",
            value = "组织名称、组织等级、组织编号、修改时间",required = true)
                                Organizational organizational){

        return organizationalService.updateOrganizational(organizational);
    }
}
